<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * FreakAuth_light Class to handle the front controller
 * this class make code more reusable and it makes easier to
 * integrate Freakauth_light in your on templating system
 *
 * The class requires the use of
 *
 * -----------------------------------------------------------------------------
 * Copyright (C) 2009 TechPundits (tech-pundits.com)
 * -----------------------------------------------------------------------------
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *------------------------------------------------------------------------------
 * @package     Maa Screen 2009-09-25
 * @subpackage  Libraries
 * @category    Authentication
 * @author      pradeep kumar
 * @copyright   Copyright (c) 2009,TechPundits (tech-pundits.com)
 * @license		http://www.gnu.org/licenses/lgpl.html
 * @link 		http://tech-pundits.com
 * 
 *
 */
class MAA_home{
	
	function MAA_home(){
		$this->CI = &get_instance();
		//loads necessary libraries
	
        
       
	}
	
	function left_block($heading)
	{
		$video_time='';
		$image_link='';
		$image_loc = '';
		$details = array();
		switch ($heading)
		{
			 ;
			case 'Wallpaper':
				$details= array();
					$temp = $this->get_wallpaper(0);
					$count = 0;
					foreach ($temp['0'] as $item)
					{
						$details[$count]->link = 'wallpapers/display/'.$item->id;
						$details[$count]->heading = $item->catname; 
						$count++;
					}
					if(!empty($temp['1']))
					{
					$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size1.jpg';
                    $image_loc = base_url().'assets/wallpapers/thumbnail'.$temp['1']['0']->id.'.jpg';
					}
					$more_link = base_url().'wallpapers';
					break;
			case 'Actors':
					$temp = $this->get_wallpaper(1);
					
					$count = 0;
					foreach($temp['0']  as $item)
					{
						$details[$count]->link = 'wallpapers/display/'.$item->id;
						$details[$count]->heading = $item->catname; 
						$count++;
					}
					if(!empty($temp['1']))
					{
					$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size1.jpg';
					$image_loc = base_url().'assets/wallpapers/thumbnail'.$temp['1']['0']->id.'.jpg';
					}
					
					$more_link =  base_url().'wallpapers/details/1';
					break;
					
			case 'Movies':
					$temp = $this->get_wallpaper(2);
					$count = 0;
					foreach($temp['0'] as $item)
					{
						$details[$count]->link = 'wallpapers/display/'.$item->id;
						$details[$count]->heading = $item->catname; 
						$count++;
					}
					if(!empty($temp['1']))
					{
					$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size1.jpg';
					$image_loc = base_url().'assets/wallpapers/thumbnail'.$temp['1']['0']->id.'.jpg';
					}
					
					$more_link = base_url().'wallpapers/details/2';;
					break;

			case 'Miss india':
					$temp = $this->get_wallpaper(3);
					$count = 0;
					foreach($temp['0']  as $item)
					{
						$details[$count]->link = 'wallpapers/display/'.$item->id;
						$details[$count]->heading = $item->catname; 
						$count++;
					}
					$more_link = base_url().'wallpapers/details/3';;
					if(!empty($temp['1']))
					{
					$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size1.jpg';
					$image_loc =  base_url().'assets/wallpapers/thumbnail'.$temp['1']['0']->id.'.jpg';
					}
					break;
					
			case 'Hot Videos':
				$temp =$this->get_videos(0);
					$count = 0;
					//print_r($temp);
					foreach($temp['0'] as $item)
					{
						$details[$count]->link = 'video/playvideo/'.$item->id.'/'.$item->video_cat_id;
						$details[$count]->heading = $item->name; 
						$count++;
					}
					if(!empty($temp['1']['0']))
					{
					$image_link = 'video/playvideo/'.$temp['1']['0']->id.'/'.$temp['1']['0']->video_cat_id;						
					$image_loc = base_url().'assets/videos/image_preview/thumbnail'.$temp['1']['0']->id.'.jpg';
					$video_time = $temp['1']['0']->time;		
					}
					$more_link = 'hotvideos';
					
					break;
				
//					$temp = $this->get_wallpaper(4);
//					//print_r($temp);
//					$count = 0;
//					foreach($temp['0']  as $item)
//					{
//						$details[$count]->link = 'wallpapers/display/'.$item->id;
//						$details[$count]->heading = $item->catname; 
//						$count++;
//					}
//					$more_link = base_url().'wallpapers/details/4';;
//					if(!empty($temp['1']))
//					$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size4.jpg';
//					
//					break;
					
			/*	case 'Actors':
					$temp = $this->get_Actors();
					$count = 0;
					foreach ($temp as $temp)
					{
						$details[$count]->link = 'wallpapers/display/'.$temp->id;
						$details[$count]->heading = $temp->person_name; 
						$count++;
					}
					$more_link = 'wallpaper';
					break;*/
						
			default: 
					$details = array();
					break;		
		}
		//echo $more_link;
		$data = array(
						'data' => 'somtext',
						'sub_heading'	=> $heading,
		                'details'	=> $details,
	   					'more'	=> $more_link,
		                'image_link' => $image_link,
		                'image_loc'  => $image_loc,
		                'video_time' => $video_time
		               

		);
		return $this->CI->load->view('maahome/leftblock',$data,TRUE);
	}
	function center_block($heading)
	{
		switch ($heading)
		{
			case 'Telugu Film News':
					$temp = $this->get_film_news();
					$count = 0;
					foreach ($temp as $temp)
					{
						$details[$count]->link = 'filimnews/content/'.$temp->id;
						$details[$count]->heading = $temp->heading; 
						$count++;
					}
					$more_link = 'filmnews';
					break;
			case 'Interviews':
					$temp = $this->get_interviews();
					$count = 0;
					foreach ($temp as $temp)
					{
						$details[$count]->link = 'interviews/details/'.$temp->id;
						$details[$count]->heading = $temp->person_name; 
						$count++;
					}
					$more_link = 'interviews';
					break;
					
				case 'Funny Pictures':
					$temp = $this->get_funlist();
					
					if(!empty($temp)){
					$count = 0;
					foreach ($temp as $fun)
					{
						foreach ($fun as $temp){
						$details[$count]->link = 'funlist/funlists/'.$temp['id'];
						$details[$count]->heading = $temp['catname']; 
						$count++;
						}
					}
					//print_r($details);
					}
					$more_link = 'funlist';
					break;	
					
					
			default: 
					$details = array();
					break;
		}
	 // $more_link='funlist';
	   $data = array(
						'data' => 'somtext',
						'sub_heading'	=> $heading,
	   					'details'	=> $details,
	   					'more'	=> $more_link,
						);
		return $this->CI->load->view('maahome/centerblock',$data,TRUE);
	}
	function right_block($heading,$data)
	{
		$video_time='';
		$image_link ="";
		$image_loc = '';
		$details = array();
		switch($heading)
		{
		case 'Telugu Film Videos':
					$temp =$this->get_videos(1);
					$count = 0;
					foreach($temp['0'] as $item)
					{
						//print_r($temp);exit;
						$details[$count]->link = 'video/playvideo/'.$item->id.'/'.$item->video_cat_id;
						$details[$count]->heading = $item->name; 
						$count++;
					}
					if(!empty($temp['1']['0']))
					{
					
					$image_link = 'video/playvideo/'.$temp['1']['0']->id.'/'.$temp['1']['0']->video_cat_id;
					$video_time =	$temp['1']['0']->time;				
					$image_loc = base_url().'assets/videos/image_preview/thumbnail'.$temp['1']['0']->id.'.jpg';
					
					}
                   $more_link =  base_url().'videos/displayvideos/1';
					break;
					
		case 'Fun Videos':
					$temp = $this->get_videos(2);
					$count = 0;
							
					foreach($temp['0'] as $item)
					{
						$details[$count]->link = 'video/playvideo/'.$item->id.'/'.$item->video_cat_id;
						$details[$count]->heading = $item->name; 
						$count++;
					}
					if(!empty($temp['1']['0']))
					{
					$image_link = 'video/playvideo/'.$temp['1']['0']->id.'/'.$temp['1']['0']->video_cat_id;
					$video_time =	$temp['1']['0']->time;							
					$image_loc = base_url().'assets/videos/image_preview/thumbnail'.$temp['1']['0']->id.'.jpg';
					
					}
                    $more_link =  base_url().'videos/displayvideos/2';
					break;
					
	    case 'Telugu Film Trailors':
					$temp = $this->get_trailors();
					$count = 0;
					foreach($temp as $item)
					{
						$details[$count]->link = 'trailors/details/'.$item->id;
						$details[$count]->heading = $item->movie_name; 
						$count++;
					}
					if(!empty($temp))
					{
					$image_link =  base_url().'trailors/details/'.$temp['0']->id;
					$video_time =	$temp['0']->time_sec;							
					$image_loc  = base_url().'assets/trailors/preview_image/thumbnail'.$temp['0']->t_id.'.jpg';
					}
					$more_link = base_url().'movie_trailors';
					//print_r($details);
					break;
					
		case 'Movie Reviews':
					$temp = $this->get_reviews();
					$count = 0;
					foreach($temp as $temp)
					{
						$details[$count]->link = 'reviews/details/'.$temp->id;
						$details[$count]->heading = $temp->movie_name; 
						$count++;
					}
					//$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size4.jpg';
					$more_link = 'hotvideos';
					//print_r($details);
					break;
					
    	case 'Movie Gossips':
					$temp = $this->CI->Interviews_Model->get_gossips_details($id="",$start=0,$order='desc',$count=false,$limit=7);
					$count = 0;
					//print_r($temp);
					foreach($temp as $temp)
					{
						$details[$count]->link = 'gossips/details/'.$temp->id;
						$details[$count]->heading = $temp->description; 
						$count++;
					//print_r($details);			
					}
					//$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size4.jpg';
					$more_link = base_url().'videos/displayvideos/0';
					break;
								
					
		default: 	$details = array();
					$more_link ='';
					break;	
					
		}
		$data = array( 	'data'        => $data,
						'sub_heading' => $heading,
		                'details'	=> $details,
	   					'more'	=> $more_link,
		                'image_link'  => $image_link,
		                'image_loc'  =>  $image_loc,
		                'video_time'  => $video_time
						);
		return $this->CI->load->view('maahome/rightblock',$data,TRUE);
	}
	function flash_block()
	{
//			    $this->CI->load->model('Slideimages_model');
//			$slideimagequery = $this->CI->Slideimages_model->show();
//		$slides = $slideimagequery->result();
//
//				$output ="<result>";
//   $i=1;
//  foreach($slides as $item)
//  {
//  $output.="<item position='$i'><id>".$item->id."</id>";
//  $output.= "<title>".$item->title."</title></item>";
//  $i++;
//   }
//  $output.="</result>";
// 
//   return $output;
              $data = array( 	'data'        => '',
						
						);
      return $this->CI->load->view('maahome/flash_block',$data,TRUE);
}
  function gallery_block()
  {
  	 $data = array( 	'data'        => '',
						
						);
      return $this->CI->load->view('maahome/gallery_block',$data,TRUE);
  }
	function gossips_block($heading)
	{
		$more_link ="";
		switch($heading)
		{
			
		case 'Movie Reviews':
					$temp = $this->get_reviews();
					$count = 0;
					foreach($temp as $temp)
					{
						$details[$count]->link = 'reviews/details/'.$temp->id;
						$details[$count]->heading = $temp->movie_name; 
						$count++;
					}
					//$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size4.jpg';
					$more_link =  base_url().'videos/displayvideos/';
					//print_r($details);
					break;
					
    	case 'Movie Gossips':
					$temp = $this->CI->Interviews_Model->get_gossips_details($id="",$start=0,$order='desc',$count=false,$limit=6);
					$count = 0;
					//print_r($temp);
					foreach($temp as $temp)
					{
						$details[$count]->link = 'gossips/details/'.$temp->id;
						$details[$count]->heading = $temp->person_name; 
						$count++;
					//print_r($details);			
					}
					//$image_link = base_url().'assets/wallpapers/image'.$temp['1']['0']->id.'_size4.jpg';
					$more_link = 'hotvideos';
					break;
		}
								
		$data = array( 	'data'        => 'sometext',
						'sub_heading' => $heading,
		                'details'	=> $details,
	   					'more'	=> $more_link,
		             //   'image_link'  => $image_link
						);
		return $this->CI->load->view('maahome/gossipsblock',$data,TRUE);
	}
	function funlist_block($heading)
	{
		$details=array();
		$temp =$this->get_funlist();
					$count = 0;
					//print_r($temp);
					foreach($temp as $temp)
					{
						//print_r($temp);
						$details[$count]->link = 'funlist/funlists/'.$temp['0']->parentid;
						$details[$count]->heading = $temp['0']->catname; 
						$details[$count]->id = $temp['0']->id;	
						$count++;
						//echo $count;				
					}
					//print_r($details);
					$more_link = 'hotvideos';
					$data = array(
		             	'data'        => 'sometext',
						'sub_heading' => $heading,
		                'details'	=> $details,
	   					'more'	=> $more_link,
						);
		return $this->CI->load->view('maahome/funlistblock',$data,TRUE);
	}
	
	function get_film_news()
	{
		$news_details=$this->CI->Filmnews_Model->select("",0,'desc');
		return $news_details;
	}
   function get_interviews()
	{
		$details = $this->CI->Interviews_Model->get_interview_fulldetails('',10,'');
		return $details;
	}
	
   function get_funlist()
   {
    	$categeories =$this->CI->Funlist_model->recent_categeories();
    	foreach($categeories as $item)
    	{
    		$temp=$this->CI->Funlist_model->funlists($item->id,'yes');
    		$details[]=$temp->result();
    		
    	}
    	//print_r($details);
		return $details;
   }
   function get_wallpaper($id)
   {
   	$homepage_image="";
   		$this->CI->load->model('Wallpapermain');
    	$details =$this->CI->Wallpapermain->get_subcategeories($id,0,4);
    	if(!empty($details)){
    	$homepage_image =$this->CI->Wallpapermain->homepage_image($details['0']->id);
    	}
		return array($details,$homepage_image);
   }
   function get_videos($id)
   {
     	$this->CI->load->model('Videos_model');
    	$details = $this->CI->Videos_model->get_homevideos($id);
    	$image_link = $this->CI->Videos_model->get_homevideoimage($id);
    	return array($details,$image_link);
   }
   function get_trailors()
   {
   	$this->CI->load->model('admin/Trailors_Model');
   	$details =$this->CI->Trailors_Model->get_trailors_home('',6);
   	return $details;
    	
   }
   function get_reviews()
   {
   	$this->CI->load->model('Reviews_Model');
   	$details = $this->CI->Reviews_Model->get_home_reviews();
   	return $details;
    	
   }
   function get_gossips()
   {
   	$this->CI->load->model('Interviews_Model');
   	$details = $this->CI->Interviews_Model->get_gossips_details($id="",$start=0,$order='desc',$count=false,$limit=7);
   	return $details;				
   }
}